package jf.collections.primitive;

import java.util.List;
import java.util.Collection;
import java.util.Iterator;
import java.util.Arrays;

import jf.collections.ListX;
import jf.collections.ArrayListX;
import jf.collections.AbstractListX;
import jf.collections.iterators.RightIterator;

/**
 * @author ivanalx
 * @date 01.06.2009 14:17:40
 */
public class DirectArrayList<A> extends AbstractListX<A> implements ListX<A> {
	private List<A> directArray;

	public DirectArrayList(A... a) {
		directArray = Arrays.asList(a);
	}

	@Override
	protected List<A> getBaseCollection() {
		return directArray;
	}

	@Override
	public Iterator<A> rightIterator() {
		return new RightIterator<A>(this);
	}

	@Override
	public <B> ListX<B> createNewList(int capacity) {
		return new ArrayListX<B>(capacity);
	}

	@Override
	public <B> ListX<B> createNewList() {
		return new ArrayListX<B>();
	}

	@Override
	public <B> ListX<B> createNewList(Collection<? extends B> inital) {
		return new ArrayListX<B>(inital);
	}
}
